#ifndef NETWORKSTATUSDIALOG_H
#define NETWORKSTATUSDIALOG_H

#include <QDialog>
#include <QLabel>
#include <QPushButton>
#include <QGroupBox>
#include <QVBoxLayout>
#include <QHBoxLayout>
#include <QGridLayout>
#include <QFrame>
#include "networkinfo.h"
#include <QTimer>

class NetworkStatusDialog : public QDialog {
    Q_OBJECT
public:
    explicit NetworkStatusDialog(const ConnectionInfo &connInfo, const DeviceInfo &devInfo, NetworkInfo *networkInfo, QWidget *parent = nullptr);
    void setStats(const NetworkStats &stats);
    ~NetworkStatusDialog();

private:
    // 常规区
    QGroupBox *groupGeneral;
    QLabel *labelIPv4;
    QLabel *labelIPv6;
    QLabel *labelMediaStatus;
    QLabel *labelDuration;
    QLabel *labelSpeed;
    QPushButton *btnDetail;
    QFrame *lineDetail;
    // 活动区
    QGroupBox *groupActivity;
    QLabel *labelActivityTitle;
    QFrame *lineActivityTop;
    QLabel *labelTx;
    QLabel *labelRx;
    QLabel *labelTxBytes;
    QLabel *labelRxBytes;
    QLabel *iconLabel;
    QFrame *lineLeft;
    QFrame *lineRight;
    QFrame *lineActivityBottom;
    QLabel *labelBytesTitle;
    QLabel *labelTxBytesValue;
    QLabel *labelRxBytesValue;
    // 标题
    QLabel *labelTitle;
    QLabel *labelConnName;
    QLabel *labelDevName;
    // 按钮区
    QPushButton *btnProperty;
    QPushButton *btnDisable;
    QPushButton *btnDiagnose;
    QPushButton *btnClose;
    QGridLayout *m_bytesGrid = nullptr;
    QHBoxLayout *m_bytesRow = nullptr;
    QSpacerItem *m_bytesSpacer = nullptr;
    QWidget *m_centerWidget = nullptr;
    QLabel *m_labelBytesTitle = nullptr;
    QLabel *m_iconLabel = nullptr;
    QLabel *m_labelTxBytesValue = nullptr;
    QLabel *m_labelRxBytesValue = nullptr;
    QTimer *m_statsTimer = nullptr;
    QString m_deviceName;
    NetworkInfo *m_networkInfo = nullptr;
    void adjustBytesGrid();
protected:
    void resizeEvent(QResizeEvent *event) override;
};

#endif // NETWORKSTATUSDIALOG_H 